package chapter02

/**
 * @program lu-scala01
 * @description:
 * @author: zhanglu
 * @create: 2022-02-14 17:49:00
 */
object C07_CollectionOp {

  def main(args: Array[String]): Unit = {
    def arrayOp(array: Array[Int], op: Int => Int) = {
      for (item <- array) yield op(item)
    }

    var arr = Array(1,2,3,4)
    val arr2 = arrayOp(arr, _ * 2)
    println(arr2.mkString(","))

    val arr3 = arrayOp(arr, x => x * x)
    println(arr3.mkString(","))
  }

}
